package com.yowasa.xiuxian.engine.travel.adventure;

import com.google.common.collect.Sets;
import com.yowasa.xiuxian.engine.travel.AdventureInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.MapEnum;
import com.yowasa.xiuxian.entity.enums.RefreshType;
import com.yowasa.xiuxian.service.helper.ItemHelper;
import com.yowasa.xiuxian.service.helper.ResourceHelper;
import com.yowasa.xiuxian.service.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 琅琊果获取
 */
@Component
public class LangYaGuoGet implements AdventureInterface {
    @Autowired
    private ItemHelper itemHelper;
    @Autowired
    private UserHelper userHelper;
    @Autowired
    private ResourceHelper resourceHelper;


    @Override
    public Set<MapEnum> limitMaps() {
        //仙人洞only
        return Sets.newHashSet(MapEnum.GUI_LI_YUAN);
    }

    @Override
    public String exec(UserBO user) {
        userHelper.lockUser(user, 20, user.getName() + "正探索秘境中");
        if (resourceHelper.checkHaveResource(user.getGuildId(), this.getClass().getName(), RefreshType.JIU_XING)) {
            resourceHelper.useResource(user.getGuildId(), this.getClass().getName());
            itemHelper.addItem(user, "琅琊果", 1);
            return "你在洞穴发现了一个琅琊果树，摘取了琅琊果*1";
        }
        return "你在洞穴发现了一个琅琊果树，但是上面的果实已经被摘走了";
    }

    @Override
    public boolean isConflict() {
        return true;
    }
}
